<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="/template/StakeholderTemplate.xhtml">

    <ui:define name="contentInsert">

        <h:form>
            <p:dataTable id="mealList" var="proposal" value="#{groupBuyingManagedBean.existingProposal}" 
                         emptyMessage="Currently no group buying items have been added"
                         dynamic ="true" paginatorPosition="top" >

                <f:facet name="header">
                    Existing group buying items
                </f:facet>

                <p:column style="width:16px">  
                    <p:rowToggler />  
                </p:column> 

                <p:column headerText="id">
                    <h:outputText id="id" value="#{proposal.id}" />
                </p:column>
                <p:column headerText="Name">
                    <h:outputText id="name" value="#{proposal.name}" />
                </p:column>
                <p:column headerText="Offered Price">
                    <h:outputText id="offeredPrice" value="#{proposal.offeredPrice}" />
                </p:column>
                <p:column headerText="Original Price">
                    <h:outputText id="oriPrice" value="#{proposal.originalPrice}" />
                </p:column>
                <p:column headerText="Submission Time">
                    <h:outputText id="subTime" value="#{proposal.submissionTime}" />
                </p:column>
                <p:column headerText="Status">
                    <h:outputText id="status" value="#{proposal.status}" />
                </p:column>
                <p:column headerText="Options">
                    <p:commandButton id="approve" value="Void" ajax="false"
                                     update="display" disabled="#{proposal.status eq 'Pending' ? false:true}"
                                     actionListener="#{groupBuyingManagedBean.deleteProposal}">
                        <f:attribute name="gbItemId" value="#{proposal.id}" />
                    </p:commandButton>
                </p:column>


                <p:rowExpansion>  
                    <h:panelGrid id="display" columns="2" cellpadding="4"  
                                 style="width:900px;"  
                                 styleClass="ui-widget-content"  
                                 columnClasses="label, value">
                        <f:facet name="header">  
                            More information...
                        </f:facet>  
                        <h:outputText value="Effective start: "/>
                        <h:outputText id="effectiveStart" value="#{proposal.effectiveStart}"/>
                        <h:outputText value="Effective start: "/>
                        <h:outputText id="effectiveEnd" value="#{proposal.effectiveEnd}"/>
                        <h:outputText value="Redemption start: "/>
                        <h:outputText id="redemptionStart" value="#{proposal.redemptionStart}"/>
                        <h:outputText value="Redemption end: "/>
                        <h:outputText id="redemptionEnd" value="#{proposal.redemptionEnd}"/>
                        <h:outputText value="Min Quota: "/>
                        <h:outputText id="minQuota" value="#{proposal.minQuota}"/>
                        <h:outputText value="Max quota: "/>
                        <h:outputText id="maxQuota" value="#{proposal.maxQuota}"/>
                        <h:outputText value="Personal quota: "/>
                        <h:outputText id="personalQuota" value="#{proposal.personalQuota}"/>
                        <h:outputText value="Require booking: "/>
                        <h:outputText id="reqBooking" value="#{proposal.requireBooking}"/>
                        <h:outputText value="Description"/>
                        <h:outputText id="description" value="#{proposal.description}"/>
                        <h:outputText value="Validation"/>
                        <h:outputText id="validation" value="#{proposal.validateRequirements}"/>
                    </h:panelGrid>

                    <br/>
                </p:rowExpansion>
            </p:dataTable>
        </h:form>

    </ui:define>

</ui:composition>
